package operation;

import book.Book;
import book.BookList;

/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2021/10/29
 * Time: 11:51
 * Description:
 */
public class ReturnOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还书籍！");
        System.out.println("请输入图书的名字:");
        String name = scanner.nextLine();
        int size = bookList.getUsedSize();
        for (int i = 0; i < size; i++) {
            Book bookCurrent = bookList.getBook(i);
            if(bookCurrent.getName().equals(name)) {
                bookCurrent.setBorrowed(false);
                System.out.println("归还成功！");
                return;
            }
        }
        System.out.println("归还失败！");
    }
}
